import 'package:flutter/material.dart';
import 'package:flutter_ebook/theme/dark_theme.dart';
import 'package:flutter_ebook/theme/light_theme.dart';

class ThemeProvider with ChangeNotifier {
  // 存储当前主题数据的私有变量
  ThemeData _themeData = lightMode;

  // 获取当前主题数据的方法
  ThemeData get themeData => _themeData;

  // 获取亮色主题的方法
  ThemeData get lightTheme => lightMode;

  // 获取暗色主题的方法
  ThemeData get darkTheme => darkMode;
  bool get isDarkMode => _themeData == darkMode;
  // 设置当前主题数据的方法
  set themeData(ThemeData themeData) {
    _themeData = themeData;
    notifyListeners(); // 通知监听者主题数据已更改
  }

  void toggleTheme() {
    if (themeData == lightMode) {
      themeData = lightTheme; // 切换到亮色主题
    } else {
      themeData = darkTheme; // 切换到暗色主题
    }
  }
}
